﻿@{
    var gridPageSize = 5;
}
<table class="adminContent">
    <tr>
        <td>
            <div id="bestsellers-byamount-grid"></div>

            <script>
                $(document).ready(function () {
                    $("#bestsellers-byamount-grid").kendoGrid({
                        dataSource: {
                            type: "json",
                            transport: {
                                read: {
                                    url: "@Html.Raw(Url.Action("BestsellersBriefReportByAmountList", "Order"))",
                                    type: "POST",
                                    dataType: "json"
                                }
                            },
                            schema: {
                                data: "Data",
                                total: "Total",
                                errors: "Errors"
                            },
                            error: function(e) {
                                display_kendoui_grid_error(e);
                                // Cancel the changes
                                this.cancelChanges();
                            },
                            pageSize: @(gridPageSize),
                            serverPaging: true,
                            serverFiltering: true,
                            serverSorting: true
                        },
                        pageable: {
                            refresh: true
                        },
                        editable: {
                            confirmation: false,
                            mode: "inline"
                        },
                        scrollable: false,
                        columns: [{
                            field: "ProductName",
                            title: "@T("Admin.SalesReport.Bestsellers.Fields.Name")"
                        }, {
                            field: "TotalQuantity",
                            title: "@T("Admin.SalesReport.Bestsellers.Fields.TotalQuantity")"
                        }, {
                            field: "TotalAmount",
                            title: "@T("Admin.SalesReport.Bestsellers.Fields.TotalAmount")"
                        }, {
                            field: "ProductId",
                            title: "@T("Admin.Common.View")",
                            width: 100,
                            template: '<a href="@Url.Content("~/Admin/Product/Edit/")#=ProductId#">@T("Admin.Common.View")</a>'
                        }]
                    });
                });
            </script>
        </td>
    </tr>
</table>